{include file="public/adminhead"}

<div class="container-fluid">

  <div class="row">
    <div class="card">
      <div class="card-body">
        <form class="form-horizontal" action="#" method="post" enctype="multipart/form-data" onsubmit="return false;">

          <div class="form-group">
            <label class="col-xs-12" >用户名</label>
            <div class="col-xs-12">
              <input class="form-control" type="text" {if $res}value="{$res.username}"{/if} name="username" placeholder="..">
              <div class="help-block">如:admin</div>
            </div>
          </div>

          <div class="form-group">
            <label class="col-xs-12" >密  码</label>
            <div class="col-xs-12">
              <input class="form-control" type="text" {if $res}value="{$res.password}"{/if} name="password" placeholder="..">
              <div class="help-block">不低于6个字节长度</div>
            </div>
          </div>

          <div class="form-group">
            <label class="col-xs-12" >用户组</label>
            <div class="col-xs-12">
              <select class="form-control" id="example-select" name="level_id" size="1">
                <option value="0">请选择</option>
                {foreach $list as $v}
                <option value="{$v.id}">{$v.name}</option>
                {/foreach}
              </select>
              <div class="help-block">请选择对应权限分组</div>
            </div>
          </div>


          <div class="form-group">
            <label class="col-xs-12">是否启用</label>
            <div class="col-xs-12">
              <div class="radio">
                <label>
                  <input type="radio" name="status" value="1"
                         {if $res}
                         {if $res.status="=1"}checked="checked"{/if}
                          {else/}
                          checked="checked"
                          {/if}

                  >
                  是
                </label>
              </div>
              <div class="radio">
                <label >
                  <input type="radio" name="status" value="0" {if $res}{if $res.status="=0"}checked="checked"{/if}{/if} >
                  否
                </label>
              </div>
            </div>
          </div>

          <div class="form-group">
            <div class="col-xs-12">
              <button class="btn btn-primary" type="button" onclick="sub()">提交</button>
            </div>
          </div>
        </form>

      </div>
    </div>
  </div>

</div>

{include file="public/afooter"}

<script>
function sub() {
    var formdata = $("form").serialize();
    var url = "{:url('addadmin')}";
    $.post(url,formdata,function (e) {
      if(e.code == 200){
          success("成功");
          var index = parent.layer.getFrameIndex(window.name);
          setTimeout(function(){parent.layer.close(index)}, 2000);
          window.parent.location.reload();
      }else {
          error(e.msg);
      }
    })
}
</script>